<template>
    <div>
        <el-form :model="search_form"
            class="search_prod"
            label-width="120px">
            <el-form-item label="用户昵称">
                <el-col :span="4">
                    <el-col :span="16"
                        class="search_input_width">
                        <el-input size="small"
                            clearable
                            placeholder="请输入用户昵称"
                            v-model="search_form.nickname"></el-input>
                    </el-col>
                </el-col>
                <el-col class="tr col_label"
                    :span="3">用户账号&nbsp;&nbsp;&nbsp;</el-col>
                <el-col :span="4">
                    <el-col :span="16"
                        class="search_input_width">
                        <el-input size="small"
                            clearable
                            placeholder="请输入用户账号"
                            v-model="search_form.username"></el-input>
                    </el-col>
                </el-col>
                <el-col class="tr col_label"
                    :span="3">分配状态&nbsp;&nbsp;&nbsp;</el-col>
                <el-col :span="4">
                    <el-col :span="16"
                        class="search_input_width">
                        <el-select v-model="search_form.status"
                            placeholder="请选择分配状态"
                            clearable
                            size="small">
                            <el-option v-for="(item,k) in type_option"
                                :key="k"
                                :label="item.label"
                                :value="item.value">
                            </el-option>
                        </el-select>
                    </el-col>
                </el-col>
            </el-form-item>
            <el-form-item label="币种">
                <el-col :span="4">
                    <el-col :span="16"
                        class="search_input_width">
                        <el-select v-model="search_form.cate"
                            placeholder="请选择币种"
                            clearable
                            size="small">
                            <el-option v-for="(item,k) in coin_option"
                                :key="k"
                                :label="item.label"
                                :value="item.value">
                            </el-option>
                        </el-select>
                    </el-col>
                </el-col>
                <el-col class="tr col_label"
                    :span="3">分配时间&nbsp;&nbsp;&nbsp;</el-col>
                <el-col :span="4">
                    <el-col :span="24">
                        <el-date-picker style="width:100%"
                            v-model="distribution_time"
                            type="datetimerange"
                            size="small"
                            align="right"
                            unlink-panels
                            value-format="timestamp"
                            range-separator="-"
                            clearable
                            start-placeholder="分配时间起"
                            end-placeholder="分配时间止"
                            :picker-options="pickerOptions2">
                        </el-date-picker>
                    </el-col>
                </el-col>
                <el-col class="tr col_label"
                    :span="3">有效时间&nbsp;&nbsp;&nbsp;</el-col>
                <el-col :span="4">
                    <el-col :span="24">
                        <el-date-picker style="width:100%"
                            v-model="effective_time"
                            type="datetimerange"
                            size="small"
                            align="right"
                            unlink-panels
                            value-format="timestamp"
                            range-separator="-"
                            clearable
                            start-placeholder="有效时间起"
                            end-placeholder="有效时间止"
                            :picker-options="pickerOptions2">
                        </el-date-picker>
                    </el-col>
                </el-col>
            </el-form-item>
            <el-form-item label="释放时间">
                <el-col :span="4">

                    <el-col :span="24">
                        <el-date-picker style="width:100%"
                            v-model="freed_time"
                            type="datetimerange"
                            size="small"
                            align="right"
                            unlink-panels
                            value-format="timestamp"
                            range-separator="-"
                            clearable
                            start-placeholder="释放时间起"
                            end-placeholder="释放时间止"
                            :picker-options="pickerOptions2">
                        </el-date-picker>
                    </el-col>

                </el-col>
                <el-col class="tr col_label"
                    :span="3">执行时间&nbsp;&nbsp;&nbsp;</el-col>
                <el-col :span="4">
                    <el-col :span="24">
                        <el-date-picker style="width:100%"
                            v-model="carried_time"
                            type="datetimerange"
                            size="small"
                            align="right"
                            unlink-panels
                            value-format="timestamp"
                            range-separator="-"
                            clearable
                            start-placeholder="执行时间起"
                            end-placeholder="执行时间止"
                            :picker-options="pickerOptions2">
                        </el-date-picker>
                    </el-col>
                </el-col>
                <el-col class="tr col_label"
                    :span="3">可分配时间&nbsp;&nbsp;&nbsp;</el-col>
                <el-col :span="4">

                    <el-col :span="24">
                        <el-date-picker style="width:100%"
                            v-model="assignable_time"
                            type="datetimerange"
                            size="small"
                            align="right"
                            unlink-panels
                            value-format="timestamp"
                            range-separator="-"
                            clearable
                            start-placeholder="可分配时间起"
                            end-placeholder="可分配时间止"
                            :picker-options="pickerOptions2">
                        </el-date-picker>
                    </el-col>

                </el-col>
            </el-form-item>
            <el-form-item>
                <el-row class="tl">
                    <el-col :span="24">
                        <el-button size="mini"
                            type="primary"
                            @click="order_search_btn">查询</el-button>
                        <el-button size="mini"
                            type="primary"
                            @click="del_search_btn">一键清除</el-button>
                    </el-col>
                </el-row>
            </el-form-item>

        </el-form>
    </div>
</template>
<script>
export default {
    name: "virtual_wallet_search",
    data () {
        return {
            distribution_time: [],
            effective_time: [],
            freed_time: [],
            carried_time: [],
            assignable_time: [],
            pickerOptions2: {
                disabledDate (time) {
                    return time.getTime() > Date.now();
                },
                shortcuts: [
                    {
                        text: "最近一周",
                        onClick (picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit("pick", [start, end]);
                        }
                    },
                    {
                        text: "最近一个月",
                        onClick (picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit("pick", [start, end]);
                        }
                    },
                    {
                        text: "最近三个月",
                        onClick (picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit("pick", [start, end]);
                        }
                    }
                ]
            },
            type_option: [
                {
                    label: "空闲",
                    value: "0"
                },
                {
                    label: "已分配",
                    value: "1"
                },
                {
                    label: "手动提币中",
                    value: "2"
                }
            ],
            coin_option: [
                {
                    label: "ETH",
                    value: "0"
                }
            ],
            search_form: {
                username: "",
                nickname: "",
                status: "",
                cate: "",
                distribution_time_begin: "",
                distribution_time_end: "",
                effective_time_begin: "",
                effective_time_end: "",
                freed_time_begin: "",
                freed_time_end: "",
                carried_time_begin: "",
                carried_time_end: "",
                assignable_time_begin: "",
                assignable_time_end: ""
            }
        };
    },
    components: {},
    methods: {
        del_search_btn () {
            this.distribution_time = [];
            this.effective_time = [];
            this.freed_time = [];
            this.carried_time = [];
            this.assignable_time = [];
            this.search_form = {
                username: "",
                nickname: "",
                status: "",
                cate: "",
                distribution_time_begin: "",
                distribution_time_end: "",
                effective_time_begin: "",
                effective_time_end: "",
                freed_time_begin: "",
                freed_time_end: "",
                carried_time_begin: "",
                carried_time_end: "",
                assignable_time_begin: "",
                assignable_time_end: ""
            };
            this.$emit("send_search", this.search_form);
        },
        order_search_btn () {
            this.$emit("send_search", this.search_form);
        }
    },
    watch: {
        distribution_time (val) {
            if (val != null) {
                this.search_form.distribution_time_begin = this.$fnc.phptime(val[0]);
                this.search_form.distribution_time_end = this.$fnc.phptime(val[1]);
            } else {
                this.search_form.distribution_time_begin = "";
                this.search_form.distribution_time_end = "";
            }
        },
        effective_time (val) {
            if (val != null) {
                this.search_form.effective_time_begin = this.$fnc.phptime(val[0]);
                this.search_form.effective_time_end = this.$fnc.phptime(val[1]);
            } else {
                this.search_form.effective_time_begin = "";
                this.search_form.effective_time_end = "";
            }
        },
        freed_time (val) {
            if (val != null) {
                this.search_form.freed_time_begin = this.$fnc.phptime(val[0]);
                this.search_form.freed_time_end = this.$fnc.phptime(val[1]);
            } else {
                this.search_form.freed_time_begin = "";
                this.search_form.freed_time_end = "";
            }
        },
        carried_time (val) {
            if (val != null) {
                this.search_form.carried_time_begin = this.$fnc.phptime(val[0]);
                this.search_form.carried_time_end = this.$fnc.phptime(val[1]);
            } else {
                this.search_form.carried_time_begin = "";
                this.search_form.carried_time_end = "";
            }
        },
        assignable_time (val) {
            if (val != null) {
                this.search_form.assignable_time_begin = this.$fnc.phptime(val[0]);
                this.search_form.assignable_time_end = this.$fnc.phptime(val[1]);
            } else {
                this.search_form.assignable_time_begin = "";
                this.search_form.assignable_time_end = "";
            }
        }
    }
};
</script>
<style scoped>
</style>
